"""Controller for current students."""

from mnemoply.controllers.lookup import LookupControllerWithFilter
from mnemoply.controllers.Student import StudentController
from turbogears import identity, expose, widgets

class StudentWithFilterController(StudentController, LookupControllerWithFilter):
    """Controller for current students."""

    filter_fields = [widgets.TextField(name = "XXX")]
    @expose()
    def show():
        self.filters.append(dict(id=1))
        return self.list()
    
    def prepare_filter(self, **kw):
        args = LookupControllerWithFilter.prepare_filter(self, **kw)
        student = "''"
        if kw.has_key("XXX") and kw["XXX"] :
            student = kw["XXX"]
        if student!="''" or args.has_key("flt_surname"):
            args["flt_surname"] = "="+student
        return args
    @expose()
    def list(self):
        self.default_filters = {"surname":"=''"}
        return LookupControllerWithFilter.list(self)

exposed = StudentWithFilterController()
